[19.0][ADD] sale_section_stock_move#4261
Conversation
9b87573 to
c507ec5
Compare
c507ec5 to
e68503d
Compare
| class StockMove(models.Model): | ||
| _inherit = "stock.move" | ||
|
|
||
| sale_section_id = fields.Many2one( |
There was a problem hiding this comment.
is this relevant for ALL moves and move lines? 🤔
A change on so line section might have a big perf impact. no?
There was a problem hiding this comment.
is this relevant for ALL moves and move lines?
The fields are added on stock.move and stock.move.line, so the columns exist for all records, but they’ll only be filled (non-null) for moves/move lines that come from a sale order line (sale_line_id) and where that sale line has a section (section_id). For other moves (inventory, manufacturing, purchase, etc.) it stays empty.
A change on so line section might have a big perf impact. no?
It can, yes.
Because sale_section_id / sale_section_name are stored related fields, if you change the section on a sale order line, Odoo may need to recompute + write the stored value on all dependent records:
- all stock.move linked to that sale line (sale_line_id)
- and then all stock.move.line linked to those moves
So if someone bulk-updates sections on confirmed orders with lots of moves/move lines, that can trigger a large cascade of writes (and be noticeable on big DBs).
If section changes are rare, the impact is usually limited.
Another option:
Make sale_section_* non-stored computed/related fields.
- Pros: changing the section won’t trigger mass writes on moves/move lines.
- Cons: you generally lose efficient search/group-by on those fields (or it becomes slower because it computes on the fly).
e68503d to
f232511
Compare
|
This PR has the |
This module propagates sale order section information to stock
operations.
It adds a Sale Section on stock moves from the related sale order line
section, and exposes the section name on stock moves and stock move
lines.
The section information is available in stock move and stock move line
list views, search filters, group by options, and in the Operations tab
of stock pickings.
Depends of #4260